package bpm.dao.impl.document;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import bpm.domain.document.Attachment;
/**
 * 
 * @author ZhaoWangLong Jul 26, 2011
 *
 */
public class AttachmentBatchPreparedStatement implements
		BatchPreparedStatementSetter {
	private List<Attachment> attachments;
	
	public AttachmentBatchPreparedStatement(List<Attachment> attachments){
		this.attachments=attachments;
	}
	public AttachmentBatchPreparedStatement(){}
	public int getBatchSize() {
		return attachments.size();
	}
	public void setValues(PreparedStatement ps, int i) throws SQLException {
		ps.setString(1,attachments.get(i).getId());
		ps.setInt(2,attachments.get(i).getType().getId());                                         
		ps.setString(3,attachments.get(i).getReferencedResourceType().name());                    
		ps.setString(4,attachments.get(i).getReferencedResourceId());                                 
		ps.setString(5,attachments.get(i).getOwnedDocument().getId());     
		ps.setString(6, attachments.get(i).getPaperString());
		ps.setString(7,attachments.get(i).getTitle());
		ps.setInt(8, attachments.get(i).getSize());
		ps.setString(9,attachments.get(i).getCreator().getId());                                      
		ps.setString(10,attachments.get(i).getCreator().getName());                                    
		ps.setString(11,attachments.get(i).getLastUpdater().getId());                                  
		ps.setString(12,attachments.get(i).getLastUpdater().getName());                                
		ps.setDate(13,new java.sql.Date(attachments.get(i).getCreateTime().getTime()));              
		ps.setDate(14,new java.sql.Date(attachments.get(i).getLastUpdateTime().getTime()));          
		ps.setString(15,attachments.get(i).getDescription());
		ps.setString(16, attachments.get(i).getScope());
	}

}
